/**
 * @param {string} s
 * @return {string[][]}
 */
let isisPalindrome = (str)=>{
    let l=0,
        r=str.length-1
    while(r>l){
        if(str[l]!==str[r]) return false
        l++
        r--
    }
    return true
}

 var partition = function(s) {
    let res = [],curr=[];
    const tools = (starIndex)=>{
        if(starIndex>=s.length) {
            res.push([...curr])
            return
        }
        for(let i=starIndex;i<s.length;i++){
            let str = s.slice(starIndex,i+1)
            if(!isisPalindrome(str))continue
            curr.push(str)
            tools(i+1)
            curr.pop()
        }
    }
    tools(0)
    return res
};
console.log(partition("aab"));